#include "Globals.h"
#include "ishader.h"

//--------------------------------------------------------------------------------
//	initialize a vertex shader asset
//--------------------------------------------------------------------------------
void *IVertexShader::AssetInit( IAssetFile *pi, const CMasterIndexEntry *pme, void* context )
{
	CGraphics				*pGraphics	= (CGraphics*)context;
	IDirect3DVertexShader9	*pvs		= 0;
	void					*ptr;

	ptr = pi->GetChunk(pme->nameHash,pme->primaryChunk);
	if( ptr )
	{	// create the vertex shader
		pvs = pGraphics->CreateVertexShader(ptr);
	}
	return (void*)pvs;
}

//--------------------------------------------------------------------------------
//	uninitialize a vertex shader asset
//--------------------------------------------------------------------------------
void IVertexShader::AssetUninit( void *ptr, void* context )
{
	IDirect3DVertexShader9	*pvs = (IDirect3DVertexShader9 *)ptr;
	pvs->Release();
}

//--------------------------------------------------------------------------------
//	fixup an asset
//--------------------------------------------------------------------------------
void IVertexShader::AssetFixup( CAssetFileMgr *pMgr, const IAssetFile *pFile, void *ptr, const CMasterIndexEntry *pEntry )
{
}

//--------------------------------------------------------------------------------
//	initialize a pixel shader asset
//--------------------------------------------------------------------------------
void *IPixelShader::AssetInit( IAssetFile *pi, const CMasterIndexEntry *pme, void* context )
{
	CGraphics				*pGraphics	= (CGraphics*)context;
	IDirect3DPixelShader9	*pps		= 0;
	void					*ptr;

	ptr = pi->GetChunk(pme->nameHash,pme->primaryChunk);
	if( ptr )
	{	// create the vertex shader
		pps = pGraphics->CreatePixelShader(ptr);
	}
	return (void*)pps;
}

//--------------------------------------------------------------------------------
//	uninitialize a vertex shader asset
//--------------------------------------------------------------------------------
void IPixelShader::AssetUninit( void *ptr, void* context )
{
	IDirect3DPixelShader9	*pps = (IDirect3DPixelShader9 *)ptr;
	pps->Release();
}

//--------------------------------------------------------------------------------
//	fixup an asset
//--------------------------------------------------------------------------------
void IPixelShader::AssetFixup( CAssetFileMgr *pMgr, const IAssetFile *pFile, void *ptr, const CMasterIndexEntry *pEntry )
{
}

